﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
using Game.Plugin.Parse;
using Game.Surface;

namespace SL
{
    public partial class CommandWindow 
    {
        public CommandWindow(AppSurfaceControl surfaceControl)
        {
            DebugPlugin.DebugPlugin.Instance.Init(
                surfaceControl.GameController.CommandExecutor,
                surfaceControl.GameMapView,
                surfaceControl.GameController.GameLevels);
            InitializeComponent();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void textBox1_TextInput(object sender, TextCompositionEventArgs e)
        {
            string expression = textBox1.Text;
            //const string expression = "w x z - +";
            var sentence = new Evaluator(expression);
            var variables = new Dictionary<string, ICodeObject>();
            variables["w"] = new Number(5);
            variables["x"] = new Number(10);
            variables["z"] = new Number(42);
            object result = sentence.Interpret(variables);
            textBox2.Text += "" + result + "\r\n";
        }
    }
}

